package com.example.chengyu.testmvvm;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.example.chengyu.testmvvm.databinding.ActivityMainBinding;
import com.example.chengyu.testmvvm.recyclerTest.SecondActivity;

import java.util.Date;

public class MainActivity extends AppCompatActivity {

    private User mUser;
    private MyHandler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = DataBindingUtil.setContentView(this,R.layout.activity_main);
        mUser = new User("123","321");
        handler = new MyHandler();
        binding.setUser(mUser);
        binding.setHandler(handler);
        binding.setTime(new Date());
    }

    public void changeName(View view){
        mUser.setFirstName("aaa");
        mUser.setLastName("bbb");
    }
    public void goNext(View view){
        Intent intent = new Intent(MainActivity.this, SecondActivity.class);
        startActivity(intent);
    }
}
